package cn.wizzer.app.web.modules.controllers.platform.bus;

import cn.wizzer.app.bus.modules.models.YJbxx;
import cn.wizzer.app.bus.modules.models.YJbxxJyxm;
import cn.wizzer.app.bus.modules.models.YJbxxLcxx;
import cn.wizzer.app.bus.modules.models.YJbxxLzxx;
import cn.wizzer.app.bus.modules.services.YJbxxJyxmService;
import cn.wizzer.app.bus.modules.services.YJbxxLcxxService;
import cn.wizzer.app.bus.modules.services.YJbxxLzxxService;
import cn.wizzer.app.bus.modules.services.YJbxxService;
import cn.wizzer.app.sys.modules.services.SysDictService;
import cn.wizzer.app.sys.modules.services.SysUnitService;
import cn.wizzer.app.sys.modules.services.SysUserService;
import cn.wizzer.app.web.commons.slog.annotation.SLog;
import cn.wizzer.app.web.commons.utils.DateUtil;
import cn.wizzer.app.web.commons.utils.ExcelUtil;
import cn.wizzer.app.web.commons.utils.ShiroUtil;
import cn.wizzer.app.web.commons.utils.StringUtil;
import cn.wizzer.app.web.modules.controllers.platform.bus.excelvo.RWDExcel;
import cn.wizzer.framework.base.Result;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.integration.json4excel.J4EColumn;
import org.nutz.integration.json4excel.J4EConf;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;


/**
 * 样品移交  虞秀斌  2019-11
 */
@IocBean
@At("/platform/bus/rwgl")
public class RwglController {
    private static final Log log = Logs.get();
    @Inject
    private YJbxxService yjbxxService;
    @Inject
    private YJbxxLcxxService yjbxxlcxxservice;
    @Inject
    private SysDictService sysDictService;
    @Inject
    private SysUserService sysUserService;
    @Inject
    private SysUnitService sysUnitService;
    @Inject
    private ShiroUtil shiroUtil;
    @Inject
    private YJbxxLzxxService yjbxxlzxxservice;
    @Inject
    private YJbxxJyxmService yjbxxjyxmservice;
    @At("/?")
    @Ok("beetl:/platform/bus/rwgl/list.html")
    @RequiresPermissions(value = {"bus.rwgl.rwfp","bus.rwgl.rwrl","bus.rwgl.rwch"},logical = Logical.OR)
    public void index(String operation,HttpServletRequest req) {
        req.setAttribute("jylxMap", JSONObject.fromObject(sysDictService.getCodeMap("jylx")));
        String lczt="";
        if(operation.equals("rwfp")){
            lczt="1,3";
        }
        else if(operation.equals("rwrl")){
            lczt="1,3";
        }
        else if(operation.equals("rwch")){
            lczt="2,4";
        }
        req.setAttribute("lczt",lczt);
        req.setAttribute("operation",operation);
        req.setAttribute("userId",shiroUtil.getPrincipalProperty("id").toString());
        req.setAttribute("username",shiroUtil.getPrincipalProperty("username").toString());
        req.setAttribute("lcztMap", JSONObject.fromObject(sysDictService.getCodeMap("lczt")));
        req.setAttribute("lzztMap", JSONObject.fromObject(sysDictService.getCodeMap("lzzt")));
        req.setAttribute("unitOptions", JSONArray.fromObject(sysUnitService.getJybmTree()));



    }

    @At
    @Ok("json:{locked:'password|salt',ignoreNull:false}")
    @RequiresPermissions("bus.rwgl")
    public Object data(@Param("searchKeyword") String searchKeyword,@Param("lczt") String lczt, @Param("operation") String operation,@Param("fpzt") String fpzt,
                       @Param("jypcsk") String jypcsk,@Param("jypcjs") String jypcjs, @Param("pageNumber") int pageNumber,
                       @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
        try {
            String sql ="SELECT jbxx.id,jbxx.lzzt,jbxx.status,jbxx.jypc,jbxx.lczt, jbxx.ypbh,jbxx.bgbh, jbxx.ypmc, jbxx.jylx, jbxx.jyks, jbxx.wtdw, jbxx.ggxh, jbxx.scrqpc, jbxx.sb, jbxx.wcqx, '' AS sysj, jbxx.jyfy,FROM_UNIXTIME(jbxx.opAt) as tjsj,jl.nextSpr " +
                    " FROM y_jbxx jbxx LEFT JOIN y_jbxx_lcxx jl on jl.jbxxId=jbxx.id and jl.lczt=2 and jl.delFlag=0 where 1=1  and jbxx.lzzt>0 and jbxx.delflag = 0 ";
            if (Strings.isNotBlank(searchKeyword)) {
                sql+= " and (jbxx.ypbh like '%"+searchKeyword+"%' or  jbxx.ypmc like '%"+searchKeyword+"%')";
            }
            if(Strings.isNotBlank(jypcsk)){
                sql +=" and jbxx.jypc >= '"+jypcsk+"' ";
            }
            if(Strings.isNotBlank(jypcjs)){
                sql +=" and jbxx.jypc <= '"+jypcjs+"' ";
            }
            if(operation.equals("rwfp")){
                if(Strings.isNotBlank(fpzt)&&fpzt.equals("1")){
                    sql +=" and jbxx.lczt in(2,4)";
                }else{
                    sql +=" and jbxx.lczt in("+lczt+") ";
                }
            }
            else if(operation.equals("rwrl")){
                sql +=" and jbxx.lczt in("+lczt+") ";
                String unitid = shiroUtil.getPrincipalProperty("unitid").toString();
                List list = sysUnitService.list(Sqls.create("select id from sys_unit where id = '"+unitid+"' and sfjybm = 1 and delflag = 0 "));
                if(list.size()>0 ){
                    sql+= " and jbxx.jyksbh like '%"+unitid+"%' ";
                }else{

                }
            }
            else if(operation.equals("rwch")){
                sql +=" and jbxx.lczt in("+lczt+") ";
            }
            //按照数据权限过滤数据
            //sql+=StringUtil.dataScopeFilter("jbxx");
            if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
                if ("ascending".equalsIgnoreCase(pageOrderBy)) {
                    sql+= " order by jbxx."+pageOrderName+" asc,jbxx.opAt desc ";
                } else {
                    sql+= " order by jbxx."+pageOrderName+" desc,jbxx.opAt desc ";
                }
            }else{
                sql+= " order by jbxx.opAt desc ";
            }
            return Result.success().addData(yjbxxService.listPage(pageNumber,pageSize, Sqls.create(sql)));
        } catch (Exception e) {
            return Result.error();
        }
    }


    @At("/tofp/?")
    @Ok("json")
    @RequiresPermissions("bus.rwgl.tofp")
    public Object tofp(String id) {
        YJbxx obj = yjbxxService.fetchLinks(yjbxxService.fetch(id),"yjbxxjyxm", Cnd.NEW().asc("inspectionItemOrder"));
        //Map map = new HashMap();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("userOptions",JSONArray.fromObject(sysUserService.getUserS(obj.getJyksbh())));
        //map.put("yjbxxjyxm",JSONArray.fromObject(obj.getYjbxxjyxm()));
        jsonObject.put("obj",obj);
        String users = "";
        List<YJbxxLzxx> lzList = yjbxxlzxxservice.listEntity(Sqls.create("select * from y_jbxx_lzxx where jbxxId ='"+id+"' and lzzt =1 and status = '1' and delFlag=0  order by opAt asc "));
        if(lzList.size()>0){
            users =lzList.stream().map(t->t.getNextsprIds()).distinct().collect(Collectors.joining(","));
        }
        jsonObject.put("users",users);
        try {
            return Result.success().addData(jsonObject);
        } catch (Exception e) {
            return Result.error();
        }
    }

    @Aop(TransAop.READ_COMMITTED)
    @At
    @Ok("json")
    @RequiresPermissions("bus.rwgl")
    @SLog(tag = "任务分配，认领，撤回", msg = "样品:${args[0].ypbh}")
    public Object rwglDo(@Param("..") YJbxxLcxx obj,@Param("..") YJbxx jbxxObj,@Param("operation") String operation) {
        try {
            YJbxx jbxx = yjbxxService.fetch(obj.getJbxxId());
            jbxx.setLczt(obj.getLczt());
            if(operation.equals("rwfp")){
                obj.setSpyj("任务分配");
                jbxx.setJyxm(jbxxObj.getJyxm());
                jbxx.setJyyj(jbxxObj.getJyyj());
                jbxx.setJyfy(jbxxObj.getJyfy());
                jbxx.setWcqx(jbxxObj.getWcqx());
                jbxx.setLimitDay(jbxxObj.getLimitDay());
                if(obj.getYjbxxjyxm()!=null) {
                    yjbxxjyxmservice.execute(Sqls.create("delete from y_jbxx_jyxm  where jbxxid='"+jbxx.getId()+"'"));
                    for(YJbxxJyxm jyxm : obj.getYjbxxjyxm()){
                        jyxm.setJbxxId(jbxx.getId());
                        yjbxxjyxmservice.insert(jyxm);
                    }
                    /*for (YJbxxJyxm jyxm : obj.getYjbxxjyxm()) {
                        yjbxxjyxmservice.update(jyxm);
                    }*/
                }
            }else if(operation.equals("rwrl")){
                jbxx.setJypc("");
                obj.setSpyj("任务认领");
            }else if(operation.equals("rwch")){
                jbxx.setJypc("");
                obj.setSpyj("任务撤回");
            }
            yjbxxlcxxservice.execute(Sqls.create("update y_jbxx_lcxx set delflag=1 where lczt>="+jbxx.getLczt()+" and jbxxid='"+jbxx.getId()+"'"));
            yjbxxlcxxservice.insert(obj);
            yjbxxService.update(jbxx);
            yjbxxlcxxservice.clearCache();
            return Result.success("操作成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("system.error");
        }
    }

    @At("/tofps")
    @Ok("json")
    @RequiresPermissions("bus.rwgl.tofp")
    public Object tofps(@Param("ids") String ids) {
        try {
            List<NutMap> nutMaps = new ArrayList<>();
            if(StringUtils.isNotEmpty(ids)){
                List<YJbxx> list =  yjbxxService.query(Cnd.NEW().and("id","in",ids),"yjbxxjyxm", Cnd.NEW().asc("inspectionItemOrder"));
                for(YJbxx obj : list){
                    NutMap map = NutMap.NEW();
                    map.put("userOptions",JSONArray.fromObject(sysUserService.getUserS(obj.getJyksbh())));
                    map.put("jbxxId",obj.getId());
                    map.put("ypbh",obj.getYpbh());
                    map.put("jyxm",obj.getJyxm());
                    map.put("jyyj",obj.getJyyj());
                    map.put("jyfy",obj.getJyfy());
                    map.put("yplx",obj.getYplx());
                    map.put("wcqx",obj.getWcqx());
                    map.put("limitDay",obj.getLimitDay());
                    map.put("yjbxxjyxm",obj.getYjbxxjyxm());
                    String users = "";
                    List<YJbxxLzxx> lzList = yjbxxlzxxservice.listEntity(Sqls.create("select * from y_jbxx_lzxx where jbxxId ='"+obj.getId()+"' and lzzt =1 and status = '1' and delFlag=0  order by opAt asc "));
                    if(lzList.size()>0){
                        users =lzList.stream().map(t->t.getNextsprIds()).distinct().collect(Collectors.joining(","));
                    }
                    map.put("users",users);
                    nutMaps.add(map);
                }
            }
            return Result.success().addData(nutMaps);
        } catch (Exception e) {
            return Result.error();
        }
    }
    @Aop(TransAop.READ_COMMITTED)
    @At
    @Ok("json")
    @RequiresPermissions("bus.rwgl")
    @SLog(tag = "任务分配，认领，撤回", msg = "样品:${args[0].ypbh}")
    public Object rwglDos(@Param("listObj") YJbxxLcxx[] listObj,@Param("operation") String operation,@Param("jypc") String jypc) {
        try {
            for(YJbxxLcxx obj :listObj) {
                YJbxx jbxx = yjbxxService.fetch(obj.getJbxxId());
                jbxx.setLczt(obj.getLczt());
                if (operation.equals("rwfp")) {
                    jbxx.setJypc(jypc);
                    jbxx.setJyxm(obj.getJyxm());
                    jbxx.setJyyj(obj.getJyyj());
                    jbxx.setJyfy(obj.getJyfy());
                    jbxx.setWcqx(obj.getWcqx());
                    jbxx.setLimitDay(obj.getLimitDay());
                    obj.setSpyj("任务分配");
                    if (obj.getYjbxxjyxm() != null) {
                        yjbxxjyxmservice.execute(Sqls.create("delete from y_jbxx_jyxm  where jbxxid='"+jbxx.getId()+"'"));
                        for(YJbxxJyxm jyxm : obj.getYjbxxjyxm()){
                            jyxm.setJbxxId(jbxx.getId());
                            yjbxxjyxmservice.insert(jyxm);
                        }
                    }
                } else if (operation.equals("rwrl")) {
                    jbxx.setJypc("");
                    obj.setSpyj("任务认领");
                } else if (operation.equals("rwch")) {
                    jbxx.setJypc("");
                    obj.setSpyj("任务撤回");
                }
                yjbxxlcxxservice.execute(Sqls.create("update y_jbxx_lcxx set delflag=1 where lczt>=" + jbxx.getLczt() + " and jbxxid='" + jbxx.getId() + "'"));
                yjbxxlcxxservice.insert(obj);
                yjbxxService.update(jbxx);
            }
            yjbxxlcxxservice.clearCache();
            return Result.success("操作成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("system.error");
        }
    }

    @At
    @Ok("raw")
    @RequiresPermissions("bus.rwgl")
    public void export(@Param("listObj") YJbxxLcxx[] listObj,@Param("ids") String[] idds,
                       @Param("searchKeyword") String searchKeyword,@Param("lczt") String lczt, @Param("operation") String operation,@Param("fpzt") String fpzt,
                       @Param("jypcsk") String jypcsk,@Param("jypcjs") String jypcjs,@Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy,
                       HttpServletResponse response) {
        try {
            List<RWDExcel> listExcel = new ArrayList<>();
            Map storageMap =sysDictService.getIdMap("storage");
            Map yplxMap =sysDictService.getCodeMap("yplx");
            List<String> ids = new ArrayList<>();
            Cnd cnd = Cnd.NEW();
            if(listObj!=null && listObj.length>0){
                ids = Arrays.stream(listObj).map(t -> t.getJbxxId()).collect(Collectors.toList());
                int i=0 ;
                for(YJbxxLcxx obj :listObj) {
                    int a=0 ;
                    YJbxx jbxx = yjbxxService.fetch(obj.getJbxxId());
                    for(YJbxxJyxm jyxm :obj.getYjbxxjyxm()) {
                        RWDExcel rwdExcel = new RWDExcel();
                        rwdExcel.setXh((i+1)+"");
                        rwdExcel.setYpbh(obj.getYpbh());
                        rwdExcel.setCydbh(jbxx.getCydbh());
                        rwdExcel.setYpmc(jbxx.getYpmc());
                        if(StringUtils.isNotEmpty(jbxx.getStorage())){
                            rwdExcel.setStorage(StringUtil.getDict(jbxx.getStorage(),storageMap));
                        }
                        if(StringUtils.isNotEmpty(jbxx.getYpzt())){
                            rwdExcel.setYpzt(jbxx.getYpzt());
                        }
                        if(StringUtils.isNotEmpty(jbxx.getYplx())){
                            rwdExcel.setYplx(StringUtil.getDict(jbxx.getYplx(),yplxMap));
                        }
                        if(StringUtils.isNotEmpty(jbxx.getCyrq())){
                            rwdExcel.setCyrq(jbxx.getCyrq());
                        }
                        if(StringUtils.isNotEmpty(jbxx.getSzcq())){
                            rwdExcel.setScrq(jbxx.getSzcq());
                        }
                        if(StringUtils.isNotEmpty(obj.getJyyj())){
                            rwdExcel.setInspectionStandard(obj.getJyyj());
                        }
                        rwdExcel.setRowSize(obj.getYjbxxjyxm().size());
                        rwdExcel.setInspectionItemName(jyxm.getInspectionItemName());
                        rwdExcel.setInspectorMethod(jyxm.getInspectorMethod());
                        rwdExcel.setInspectorUserName(jyxm.getInspectorUserName());
                        rwdExcel.setJyks(jyxm.getInspectorUnitName());
                        rwdExcel.setRowCount(a);
                        listExcel.add(rwdExcel);
                        a++;
                    }
                    i++;
                }
            }else if(idds!=null && idds.length>0){
                ids = Arrays.stream(idds).collect(Collectors.toList());
                cnd.and("id","in",ids);
                List<YJbxx> jbxxs = yjbxxService.query(cnd,"yjbxxjyxm",Cnd.NEW().asc("inspectionItemOrder"));
                listExcel = getExcel(jbxxs,listExcel,yplxMap,storageMap);
            }else{
                if (Strings.isNotBlank(searchKeyword)&&!searchKeyword.equals("null")) {
                    cnd.and("ypbh","like","%"+searchKeyword+"%");
                    //sql+= " and (jbxx.ypbh like '%"+searchKeyword+"%' or  jbxx.ypmc like '%"+searchKeyword+"%')";
                }
                if(Strings.isNotBlank(jypcsk)&&!jypcsk.equals("null")){
                    cnd.and("jypc",">=",jypcsk);
                }
                if(Strings.isNotBlank(jypcjs)&&!jypcjs.equals("null")){
                    cnd.and("jypc","<=",jypcjs);
                }
                if(Strings.isNotBlank(operation)) {
                    if (operation.equals("rwfp")) {
                        if (Strings.isNotBlank(fpzt) && fpzt.equals("1")) {
                            cnd.and("lczt", "=", 2);
                        } else {
                            cnd.and("lczt", "in", lczt);
                        }
                    } else if (operation.equals("rwrl")) {
                        cnd.and("lczt", "in", lczt);
                        String unitid = shiroUtil.getPrincipalProperty("unitid").toString();
                        List list = sysUnitService.list(Sqls.create("select id from sys_unit where id = '" + unitid + "' and sfjybm = 1 and delflag = 0 "));
                        if (list.size() > 0) {
                            cnd.and("jyksbh", "like", "%" + unitid + "%");
                        } else {

                        }
                    } else if (operation.equals("rwch")) {
                        cnd.and("lczt", "in", lczt);
                    }
                }
                //按照数据权限过滤数据
                //sql+=StringUtil.dataScopeFilter("jbxx");
                if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
                    if ("ascending".equalsIgnoreCase(pageOrderBy)) {
                        cnd.asc(pageOrderName).desc("opAt");
                    } else {
                        cnd.desc(pageOrderName).desc("opAt");
                    }
                }else{
                    cnd.desc("opAt");
                }
                List<YJbxx> jbxxs = yjbxxService.query(cnd,"yjbxxjyxm",Cnd.NEW().asc("inspectionItemOrder"));
                listExcel = getExcel(jbxxs,listExcel,yplxMap,storageMap);
            }
            J4EConf j4eConf = J4EConf.from(RWDExcel.class);
            List<J4EColumn> jcols = j4eConf.getColumns();
            for (J4EColumn j4eColumn : jcols) {
                if ("rowSize".equals(j4eColumn.getFieldName()) || "rowCount".equals(j4eColumn.getFieldName()) ) {
                    j4eColumn.setIgnore(true);
                }
            }
            j4eConf.setSheetName(j4eConf.getSheetName()+ DateUtil.getDate());
            OutputStream out = response.getOutputStream();
            response.setHeader("content-type", "application/shlnd.ms-excel;charset=utf-8");
            //response.setHeader("content-disposition", "attachment; filename=" + new String((j4eConf.getSheetName() + ".xls").getBytes(), "ISO-8859-1"));
            //response.setHeader("content-type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            //response.setHeader("content-disposition", "attachment; filename=" + new String((j4eConf.getSheetName()+".xls").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
            //J4E.toExcel(out, listExcel, j4eConf);
            String fileName = j4eConf.getSheetName() + ".xls";
            // 现代浏览器的UTF-8编码
            String modernEncoded = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");

            response.setHeader("Content-Disposition",
                    "attachment; filename=" + modernEncoded);

            List<String> mergeColumns = new ArrayList<>();
            mergeColumns.add("xh");
            mergeColumns.add("ypbh");
            mergeColumns.add("cydbh");
            mergeColumns.add("ypmc");
            mergeColumns.add("storage");
            mergeColumns.add("ypzt");
            mergeColumns.add("inspectionStandard");
            mergeColumns.add("yplx");
            mergeColumns.add("cyrq");
            mergeColumns.add("lyrq");
            mergeColumns.add("lysl");
            mergeColumns.add("scrq");
            int[] celWitdh={5,13,13,15,15,15,20,15,15,25,25,25,25,25,20,15,15,15,15};

            // 设置列宽，例如将第一列宽度设置为256个单位（大约是10个字符宽度）
            ExcelUtil.createExcel(RWDExcel.class,out,j4eConf.getSheetName(),listExcel,j4eConf,mergeColumns,celWitdh);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage(), e);
        }
    }


    private List<RWDExcel>  getExcel(List<YJbxx> jbxxs,List<RWDExcel> listExcel,Map yplxMap,Map storageMap){
        int i=0 ;
        for(YJbxx jbxx :jbxxs) {
            int a=0 ;
            for(YJbxxJyxm jyxm :jbxx.getYjbxxjyxm()) {
                RWDExcel rwdExcel = new RWDExcel();
                rwdExcel.setXh((i+1)+"");
                rwdExcel.setYpbh(jbxx.getYpbh());
                rwdExcel.setCydbh(jbxx.getCydbh());
                rwdExcel.setYpmc(jbxx.getYpmc());
                if(StringUtils.isNotEmpty(jbxx.getStorage())){
                    rwdExcel.setStorage(StringUtil.getDict(jbxx.getStorage(),storageMap));
                }
                if(StringUtils.isNotEmpty(jbxx.getYpzt())){
                    rwdExcel.setYpzt(jbxx.getYpzt());
                }
                if(StringUtils.isNotEmpty(jbxx.getYplx())){
                    rwdExcel.setYplx(StringUtil.getDict(jbxx.getYplx(),yplxMap));
                }
                if(StringUtils.isNotEmpty(jbxx.getCyrq())){
                    rwdExcel.setCyrq(jbxx.getCyrq());
                }
                if(StringUtils.isNotEmpty(jbxx.getSzcq())){
                    rwdExcel.setScrq(jbxx.getSzcq());
                }
                if(StringUtils.isNotEmpty(jbxx.getJyyj())){
                    rwdExcel.setInspectionStandard(jbxx.getJyyj());
                }
                rwdExcel.setRowSize(jbxx.getYjbxxjyxm().size());
                rwdExcel.setInspectionItemName(jyxm.getInspectionItemName());
                rwdExcel.setInspectorMethod(jyxm.getInspectorMethod());
                rwdExcel.setInspectorUserName(jyxm.getInspectorUserName());
                rwdExcel.setJyks(jyxm.getInspectorUnitName());
                rwdExcel.setRowCount(a);
                listExcel.add(rwdExcel);
                a++;
            }
            i++;
        }
        return listExcel;
    }
}
